// 版权归 瞄你个汪 所有。使用本代码应遵守相关法律法规和Apache 2.0开源许可要求。
package top.geeke.database.seed;

import top.geeke.constants.AppConstPool;
import top.geeke.entity.SysUser;
import top.geeke.eunm.SysAccountTypeEnum;
import top.geeke.toolkit.SysUserTool;
import top.geeke.toolkit.supertable.seed.SuperSeedData;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 系统用户种子数据
 * </p>
 *
 * @author 瞄你个汪
 * @since 2024/5/26 8:13
 */
public class SysUserSeedData implements SuperSeedData<SysUser> {
    @Override
    public List<SysUser> getSeedData() {
        return new ArrayList<SysUser>(){{
            add(newInstance(1300000000101L, "superAdmin", "123456", "17396157891", "超级管理员", SysAccountTypeEnum.SysSuperAdmin, "330881198707057524", 0L, 0L, 0L, AppConstPool.PRIMARY_ID));
            add(newInstance(1300000000111L, "admin", "123456", "17396157892", "系统管理员", SysAccountTypeEnum.SysAdmin, "510113199612270414", 0L, 0L, 0L, AppConstPool.PRIMARY_ID));
            add(newInstance(1300000000112L, "user1", "123456", "17396157893", "普通账号", SysAccountTypeEnum.NormalUser, "61032419750930051X", 0L, 0L, 0L, AppConstPool.PRIMARY_ID));
            add(newInstance(1300000000113L, "user2", "123456", "17396157894", "会员", SysAccountTypeEnum.Member, "34222519960424492X", 0L, 0L, 0L, AppConstPool.PRIMARY_ID));
            add(newInstance(1300000000114L, "user3", "123456", "17396157895", "游客", SysAccountTypeEnum.Guest, "362330199603196532", 0L, 0L, 0L, AppConstPool.PRIMARY_ID));
            add(newInstance(1300000000115L, "user4", "123456", "17396157896", "其他", SysAccountTypeEnum.Guest, "620302199008310819", 0L, 0L, 0L, AppConstPool.PRIMARY_ID));
        }};
    }

    public SysUser newInstance(Long id, String account, String password, String mobile,
                               String realName, SysAccountTypeEnum accountType, String idNum,
                               Long orgId, Long managerUserId, Long posId, Long tenantId) {
        SysUser user = new SysUser();

        // 验证证件号，并根据证件号获取年龄，性别，生日，省市
        SysUserTool.setRelatedInfoByIdCardNumber(user, idNum);

        user.setId(id);
        user.setAccount(account);
        user.setPassword(SysUserTool.cryptoPassword(password, true));

        user.setMobile(mobile);
        user.setRealName(realName);

        // 默认昵称为账号类型名称
        user.setAccountType(accountType);
        user.setNickName(accountType.name());

        user.setOrgId(orgId);
        user.setPosId(posId);
        user.setManagerId(managerUserId);
        user.setTenantId(tenantId);

        return user;
    }
}
